      SUBROUTINE RDREQMT5(LUREQMT,EXPNAME,
     *    MAXEXP,MAXTGT,MAXREQEXP,MAXREQTGT,
     *    KEYREQEXP,REQEXP,REQTGT,NUMEXP,NUMTGT,LUERR,IERR)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE TOSS REQUIREMENTS FILE READER PACKAGE. IT
C READS DIRECTLY AND VIA OTHER SUBROUTINES DATA FOR THE EXPERIMENTS
C SPECIFIED IN EXPNAMES. DATA STORAGE OCCURS HERE. ERROR CHECKS ALSO.
C
C***********************************************************************
C
C BY C PETRUZZO GSFC/742  1/86
C        MODIFIED....
C
C***********************************************************************
C
      INCLUDE 'RDREQMT.INC'
C
      INTEGER*4   NUMTGT(MAXEXP),KEYREQEXP(MAXREQEXP)
      REAL*8      REQEXP(2,MAXREQEXP,MAXEXP)
      REAL*8      REQTGT(MAXREQTGT,MAXTGT,MAXEXP)
      CHARACTER*8 EXPNAME(MAXEXP)
C
      CHARACTER*8 CH8NAME
      LOGICAL FINI
C
      LOGICAL*1 LOADED(MAXEXPMTS)
C
      REAL*8 HALFPI / 1.570796326794897D0 /
      REAL*8 PI     / 3.141592653589793D0 /
      REAL*8 TWOPI  / 6.283185307179586D0 /
      REAL*8 DEGRAD / 57.29577951308232D0 /
C
C
C ****************
C *  INITIALIZE  *
C ****************
C
      IERR = 0
      NUMEXP=0
C
      DO I=1,MAXEXP
        LOADED(I) = EXPNAME(I).EQ.'  '   ! IE, NON-BLANKS ARE FALSE.
        END DO
C
C
C *****************************
C *  LOAD THE REQUESTED DATA  *
C *****************************
C
C READ THE FILE. SAVE DATA WHEN A REQUESTED EXPERIMENT IS ENCOUNTERED.
C
      REWIND LUREQMT
      FINI = .FALSE.
C
      DO WHILE(.NOT.FINI)
C
C      SKIP THE COMMENT LINE
        READ(LUREQMT,50,END=320)
   50   FORMAT(A)
C
C      READ AN EXPERIMENT NAME
        READ(LUREQMT,*,END=320) CH8NAME
C
C
C      SEE IF THIS IS AN EXPERIMENT FOR WHICH REQMTS ARE WANTED. IF SO,
C      SET IEXP TO THE ELEMENT NUMBER WHERE THE NAME MATCH OCCURRED.
C      IF NOT, SET IEXP TO ZERO.
        CALL MATCHCH(CH8NAME,MAXEXP,EXPNAME,IEXP)
C
C      CALL RDREQMT5A TO READ THE REST OF THE DATA FOR THIS EXPMT AND,
C      IF IT IS ONE THAT WE WANT, STORE INFO IN REQEXP, REQTGT, NUMTGT.
        CALL RDREQMT5A(LUREQMT,IEXP,CH8NAME,
     *           MAXEXP,MAXTGT,MAXREQEXP,MAXREQTGT,
     *           KEYREQEXP,REQEXP,REQTGT,NUMTGT, LUERR,IERR)
        IF(IERR.NE.0) GO TO 9999
        IF(IEXP.GT.0) NUMEXP = NUMEXP + 1
C
C      HAVE ALL EXPMTS BEEN LOADED ? IF SO, THE DO-WHILE ENDS.
        IF(IEXP.GT.0) LOADED(IEXP) = .TRUE.
        FINI = .TRUE.
        DO I=1,MAXEXP
          FINI = FINI .AND. LOADED(I)
          END DO
C
        END DO
C
      GO TO 9999
C
  320 CONTINUE
C
C TO GET HERE, THE PROGRAM HAD NOT FOUND ALL OF THE REQUESTED
C EXPERIMENTS AND FOUND AN END-FILE WHILE LOOKING FOR MORE EXPMTS.
C 
      IERR = 3
      IF(LUERR.GT.0) THEN
        WRITE(LUERR,9901)
     *        'ONE OR MORE REQUESTED EXPERIMENTS NOT FOUND ' //
     *              'ON THE REQMTS FILE.'
        DO I=1,MAXEXP
          IF(.NOT.LOADED(I)) WRITE(LUERR,9902) EXPNAME(I)
          END DO
        END IF
C
 9999 CONTINUE
      RETURN
C
 9901 FORMAT(/,
     *   ' OBSERVATION REQUIREMENTS FILE READER. ERROR CONDITION.'/,
     *   (5X,A))    ! ERROR MESSAGE TEXT
 9902 FORMAT(T6,' EXPMT NOT FOUND = ',A)
      END
